package org.jctc.els.modules.biz.service.message.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jctc.els.modules.biz.mapper.message.MessageObjectsMapper;
import org.jctc.els.modules.biz.service.message.IMessageObjectsService;
import org.jctc.els.modules.biz.entity.message.MessageObjects;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * <p>
 * 消息发布对象表 服务实现类
 * </p>
 *
 * @author lyh
 * @since 2021-02-26
 */
@Service
public class MessageObjectsServiceImpl implements IMessageObjectsService {

    @Autowired
    private MessageObjectsMapper messageObjectsMapper;

    @Override
    public boolean save(MessageObjects messageObjects){
        return messageObjectsMapper.insert(messageObjects)>0;
    }

    @Override
    public boolean remove(Long id){
        return messageObjectsMapper.deleteById(id)>0;
    }

    @Override
    public boolean edit(MessageObjects messageObjects){
        return messageObjectsMapper.updateById(messageObjects)>0;
    }

    @Override
    public  Page<MessageObjects> selectListByPage(Integer pageNum, Integer pageSize){
    Page<MessageObjects> messageObjectsPage = new Page<>(pageNum, pageSize);
    MessageObjects messageObjects = new MessageObjects();

    return (Page<MessageObjects> )  messageObjectsMapper.selectPage(messageObjectsPage, Wrappers.query(messageObjects));
    }

    @Override
    public MessageObjects selectById(Long id){
        return  messageObjectsMapper.selectById(id);
    }
}
